package org.jrfe.sys;

import org.lwjgl.Sys;

/**
 * 
 * @author Kalvis Freimanis
 *
 */
public class Timer {

	/** Time when reset is called */
	private long lastTime;
	
	
	/**
	 * Create new timer object
	 */
	public Timer() {
		lastTime = getSystemTime();
	}
	
	/**
	 * Reset Timer
	 */
	public void reset(){
		lastTime = getSystemTime();
	}
	
	/**
	 * Get time passed in ms since last reset call
	 * @return time in ms
	 */
	public long getDeltaMS(){
		return getSystemTime() - lastTime;
	}
	
	/**
	 * Get time passed in s since last reset call
	 * @return Time in s
	 */
	public float getDelta(){
		return getDeltaMS() / 1000.f;
	}
	
	/** 
	 * Get System time in ms
	 * @return Sytem time in ms
	 */
	public static long getSystemTime() {
		return (Sys.getTime() * 1000) / Sys.getTimerResolution();
	}
	
	
	
}
